<%@page import="service.MovieService"%>
<%@page import="entity.Movie"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="dao.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setCharacterEncoding("utf-8");
MovieService ms = new MovieService();
int mid = Integer.parseInt(request.getParameter("id"));
ArrayList<Movie> cs = ms.findone(mid);
%>
<%
	if(session.getAttribute("id")==null){
	response.sendRedirect("login.jsp");
	}%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>电影</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	 
	 <link href="css/bootstrap.css" rel="stylesheet">
  </head>
  <script src="js/jquery2.2.3.js"></script>
  <script src="js/bootstrap.js"></script>
     <script type="text/javascript">
  function check()
 {
  var password = document.getElementById('form-password');
  if(password.value=="")
  {
   alert('请输入内容');
   return false;
  }
  else{
  	return true;
  }
 }
  </script>
  <body>
    <nav class="navbar navbar-default" role="navigation">
   <div class="navbar-header">
      <a class="navbar-brand" href="index.jsp">电影网</a>
   </div>
    <div>
      <ul class="nav navbar-nav">
         <li><a href="movie.jsp">所有电影</a></li>
         <li><a href="inform.jsp">我的电影</a></li> 
      </ul>
        <% if(session.getAttribute("id")==null){ %>
      <ul class="nav navbar-nav navbar-right">
         <li><a href="login.jsp">登录</a></li>
         <li><a href="register.jsp">注册</a></li>   
      </ul>
      <%  }  else {
String uid = session.getAttribute("id").toString();
UserDao userdao = new UserDao();
String username = userdao.findById(uid);%>
      	 <ul class="nav navbar-nav navbar-right">
         <li><a>欢迎你,<%=username %></a></li>
         <li><a href="loginout.jsp">退出</a></li>   
      </ul>
      <% } %>
</div>
</nav>
  
  
  <div class="container-fluid">
	<div class="row-fluid">
	 <div class="col-sm-12">
		<div style="padding:0 270">
			<h2><%=cs.get(0).getName() %></h2>
			<img src="<%=cs.get(0).getPicture() %>" style="width:180px;float:left">
			<div style="padding-left:200px">
			  <p class="text-justify">导演：<%=cs.get(0).getDirector()%></p>
			  <p class="text-justify">主演：<%=cs.get(0).getActor() %></p>
			  <p>类型：<%=cs.get(0).getType() %></p>
			  <p>时长：<%=cs.get(0).getLength() %></p>
			  <p>简介：<%=cs.get(0).getIntroduce() %></p>
			 </div>
			</div>
	 </div>
	 <%-- <%request.setAttribute("mid", "cs.get(0).getMid())");%> --%>
	 	<div class="col-sm-12">
	 	<div class="center-block" style="width:300px">
	 		<p>请输入登录密码，完成购买</p>
	 		<form action="PurchaseServlet" method="post" class="">
	 			<input type="password" name="password" placeholder="请输入登录密码" class="form-password form-control" id="form-password">
	 			<input type="hidden" name="mid" value="<%=cs.get(0).getMid()%>">	 			
	 			<p></p>
	 			<button type="submit" class="btn btn-primary" onclick="return check()">购买！</button>
	 		</form>
	 	</div>
	 	</div>
  </div>
	
 </div>
</body>
</html>
